package com.order.server.controller;



import com.product.api.ProductApi;
import com.product.api.model.ProductInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.SpringQueryMap;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private ProductApi productApi;

    //    @Autowired
//    private OrderService orderService ;
//
//    // 根据 url来获取参数
//    @RequestMapping(value = "/{orderId}")
//    public OrderInfo getProductInfo(@PathVariable("orderId") Integer orderId){
//        return orderService .getById(orderId);
//    }
    @RequestMapping("/p1")
  public   String p1( Integer id, String name) {
        // 通过 Feign 客户端 , 执行远程调用
     return productApi.p1(id , name);
    }

    @RequestMapping("/p2")
   public   String p2(){
        ProductInfo productInfo = new ProductInfo() ;
        productInfo.setId(11);
        productInfo.setProductName("zhangsan");
        return productApi.p2(productInfo);
    }

    // 传递json
    @RequestMapping("/p3")
    public String p3(@RequestBody ProductInfo productInfo) {
     return productApi.p3(productInfo);
    }

}
